package nc.ui.uif2.actions;

import java.awt.event.ActionEvent;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import nc.ui.querytemplate.querytree.IIconDecorator;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.UIState;
import nc.ui.uif2.editor.BillTable;
import nc.ui.uif2.model.BillTableModel;

public class AddTableRowAction extends NCAction
{
  private static final long serialVersionUID = 4430131412032557310L;
  private BillTableModel model = null;

  private BillTable editor = null;

  public static final Icon ADD_ICON = new ImageIcon(IIconDecorator.class.getResource("/images/print/manage/new.gif"));

  public AddTableRowAction()
  {
    ActionInitializer.initializeAction(this, 11);
    putValue("SmallIcon", ADD_ICON);
  }

  public void doAction(ActionEvent e) throws Exception
  {
    this.model.setUiState(UIState.ADD);
  }

  protected boolean isActionEnable()
  {
    return UIState.EDIT != this.model.getUiState();
  }

  public BillTableModel getModel() {
    return this.model;
  }

  public void setModel(BillTableModel model) {
    this.model = model;
    model.addAppEventListener(this);
  }

  public BillTable getEditor() {
    return this.editor;
  }

  public void setEditor(BillTable editor) {
    this.editor = editor;
  }
}